package test.core.fun;

import java.util.Date;

import org.junit.Test;

import hyl.core.MyFun;
import hyl.core.fun.MyDate3;
import jnr.ffi.Struct.int16_t;

public class testDate3 {

//	public static void main(String[] args) {
//	 Date date = MyFun.str2Datetime("2020-12-31 23:0:0");
//		System.out.println("dateTo小分区:"+dateTo小分区(date));
//		date = MyFun.str2Datetime("2020-12-31 23:59:59");
//		System.out.println("dateTo小分区:"+dateTo小分区(date));
//		date = MyFun.str2Datetime("2021-01-01 0:1:0");
//		System.out.println("dateTo小分区:"+dateTo小分区(date));
//		

//		date = MyFun.str2Datetime("2020-01-01 0:59:59");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2020-01-01 1:0:0");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2020-01-02 1:1:0");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2020-01-02 2:1:0");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2020-12-31 23:59:59");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2021-01-01 0:1:0");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		date = MyFun.str2Datetime("2021-01-01 1:1:0");
//		System.out.println("MyDate3.dateTo小分区"+MyDate3.dateTo小分区((date));
//		
//		
//		date = MyFun.str2Date("2020-01-01");
//		System.out.println("get日90分区:"+get日90分区(date));
//		date = MyFun.str2Date("2020-02-28");
//		System.out.println("get日90分区:"+get日90分区(date));
//		date = MyFun.str2Date("2020-04-02");
//		System.out.println("get日90分区:"+get日90分区(date));
//		date = MyFun.str2Date("2020-12-31 23:59:59");
//		System.out.println("get日90分区:"+get日90分区(date));
//		date = MyFun.str2Date("2021-01-01 0:1:0");
//		System.out.println("get日90分区:"+get日90分区(date));
//		date = MyFun.str2Date("2122-01-01 0:1:0");
//		System.out.println("get日间隔:"+MyDate2.get日间隔(d根日期,date));

//
//		date = MyFun.str2Date("2020-01-01");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2020-01-07");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2020-01-08");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//
//		date = MyFun.str2Date("2020-01-31");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2021-01-01");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2022-01-01");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2022-12-31");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2023-01-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//
//		date = MyFun.str2Date("2020-01-01");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2020-02-31");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2020-04-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2020-07-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2021-01-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2022-12-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//		date = MyFun.str2Date("2023-01-02");
//		System.out.println("MyDate3.dateTo小分区:"+MyDate3.dateTo小分区(date));
//
//		date = MyFun.str2Date("2020-01-01");
//		System.out.println(get年5分区(date));
//		date = MyFun.str2Date("2024-01-01");
//		System.out.println(get年5分区(date));

//	}
	
//	@Test
	public void test_dateTo小分区() {
		 Date date = MyFun.str2Datetime("2020-12-31 23:0:0");
//			System.out.println("dateTo小分区-分:"+MyDate3.dateTo小分区(date,MyDate3.T_分));
//			//跨周期
//			date = MyFun.str2Datetime("2020-12-31 23:59:59");
//			System.out.println("dateTo小分区-分:"+MyDate3.dateTo小分区(date,MyDate3.T_分));
//			//跨年
//			date = MyFun.str2Datetime("2021-01-01 0:1:0");
//			System.out.println("dateTo小分区-分:"+MyDate3.dateTo小分区(date,MyDate3.T_分));
//			
//			date = MyFun.str2Datetime("2020-01-01 0:59:59");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-01 1:0:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-02 1:1:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-05 2:1:0");
//			//跨周期
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-05 23:1:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-05 24:1:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			date = MyFun.str2Datetime("2020-01-06 0:1:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			//跨年
//			date = MyFun.str2Datetime("2020-12-31 23:59:59");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));		
//			date = MyFun.str2Datetime("2021-01-01 1:1:0");
//			System.out.println("MyDate3.dateTo小分区-时"+MyDate3.dateTo小分区(date,MyDate3.T_时));
//			
//			
//			date = MyFun.str2Date("2020-01-01");
//			System.out.println("get日90分区:"+MyDate3.dateTo小分区(date,MyDate3.T_日));
//			//跨周期
//			date = MyFun.str2Date("2020-3-30");
//			System.out.println("get日90分区:"+MyDate3.dateTo小分区(date,MyDate3.T_日));
//			date = MyFun.str2Date("2020-3-31");
//			System.out.println("get日90分区:"+MyDate3.dateTo小分区(date,MyDate3.T_日));
//			//跨年
//			date = MyFun.str2Date("2020-12-31 23:59:59");
//			System.out.println("get日90分区:"+MyDate3.dateTo小分区(date,MyDate3.T_日));
//			date = MyFun.str2Date("2021-01-01 0:1:0");
//			System.out.println("get日90分区:"+MyDate3.dateTo小分区(date,MyDate3.T_日));
//			date = MyFun.str2Date("2122-01-01 0:1:0");
			//System.out.println("get日间隔:"+MyDate2.get日间隔(d根日期,date));
	
			date = MyFun.str2Date("2020-01-01");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
			//跨周期
			date = MyFun.str2Date("2020-01-07");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
			date = MyFun.str2Date("2020-01-08");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
			//跨年
			date = MyFun.str2Date("2020-12-31");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
			date = MyFun.str2Date("2021-01-05");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
			date = MyFun.str2Date("2021-01-06");
			System.out.println("MyDate3.dateTo小分区-周:"+MyDate3.dateTo小分区(date,MyDate3.T_周));
	
			date = MyFun.str2Date("2020-01-31");
			System.out.println("MyDate3.dateTo小分区-月:"+MyDate3.dateTo小分区(date,MyDate3.T_月));
			//跨月
			date = MyFun.str2Date("2022-02-01");
			System.out.println("MyDate3.dateTo小分区-月:"+MyDate3.dateTo小分区(date,MyDate3.T_月));

			//跨年
			date = MyFun.str2Date("2022-12-31");
			System.out.println("MyDate3.dateTo小分区-月:"+MyDate3.dateTo小分区(date,MyDate3.T_月));
			date = MyFun.str2Date("2023-01-02");
			System.out.println("MyDate3.dateTo小分区-月:"+MyDate3.dateTo小分区(date,MyDate3.T_月));
	
			date = MyFun.str2Date("2020-01-01");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2020-02-31");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2020-04-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2020-06-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2020-07-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2021-01-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2022-12-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
			date = MyFun.str2Date("2023-01-02");
			System.out.println("MyDate3.dateTo小分区-季度:"+MyDate3.dateTo小分区(date,MyDate3.T_季));
	
			date = MyFun.str2Date("2020-01-01");
			System.out.println(MyDate3.dateTo小分区(date,MyDate3.T_年));
			date = MyFun.str2Date("2024-01-01");
			System.out.println(MyDate3.dateTo小分区(date,MyDate3.T_年));
			date = MyFun.str2Date("2025-01-01");
			System.out.println(MyDate3.dateTo小分区(date,MyDate3.T_年));

	}
	//@Test
	public void test_dateToNum() {
		Date date = MyFun.str2Date("2020-01-01");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyFun.date2Str( MyDate3.numToDate(n,i)));
		}
		System.out.println("--------------------2020-6-11");
		date = MyFun.str2Date("2020-6-1");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyFun.date2Str(MyDate3.numToDate(n,i)));
		}
		System.out.println("--------------------2020-9-1");
		date = MyFun.str2Date("2020-9-1");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyFun.date2Str(MyDate3.numToDate(n,i)));
		}
		System.out.println("--------------------2020-12-1");
		date = MyFun.str2Date("2020-12-1");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyFun.date2Str(MyDate3.numToDate(n,i)));
		}
//		System.out.println("--------------------2021-11-11");
//		date = MyFun.str2Date("2021-11-11");
//		for (int i=0;i<7;i++)
//		{
//			long n= MyDate3.dateToNum(date, i);
//			System.out.println("dateToNum:"+i+":"+n);
//			System.out.println(MyDate3.numToDate(n,i));
//		}	
//		
	}
	//@Test
	public void test_numTodate() {
		Date date = MyFun.str2Date("2020-01-01");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyDate3.numToDate(n,i));
		}
		System.out.println("--------------------2020-11-11");
		date = MyFun.str2Date("2020-11-11");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyDate3.numToDate(n,i));
		}
		System.out.println("--------------------2021-11-11");
		date = MyFun.str2Date("2021-11-11");
		for (int i=0;i<7;i++)
		{
			long n= MyDate3.dateToNum(date, i);
			System.out.println("dateToNum:"+i+":"+n);
			System.out.println(MyDate3.numToDate(n,i));
		}	
		
	}
	//@Test
	public void test_nextDate() {
		Date date = MyFun.str2Date("2020-01-01 01:01");
		for (int i=0;i<7;i++)
		{
			Date d2= MyDate3.nextDate(date, i,1);
			System.out.println("dateToNum:"+i+":"+MyFun.date2Str(d2));

		}
		date = MyFun.str2Date("2020-11-11 11:11");
		for (int i=0;i<7;i++)
		{
			Date d2= MyDate3.nextDate(date, i,1);
			System.out.println("dateToNum:"+i+":"+MyFun.date2Str(d2));

		}
	}	
	
	//月分区统一36
	//@Test
	public void test_nextMon() {
		Date date = MyFun.str2Date("2020-01-01 01:01");		
		long mon=MyDate3.dateToNum(date, MyDate3.T_月);
		for (int i=0;i<37;)
		{
			i+=3;
			int d2= (int)MyDate3.nextDateNum(mon,  MyDate3.T_月,i);
			System.out.println("dateToNum:"+i+":"+d2);
		}	
	}
	//@Test
	public void test_next分区() {
		Date date = MyFun.str2Date("2021-1-01 01:01");
		
		int mon=MyDate3.dateTo小分区(date, MyDate3.T_月);
		System.out.println("分区:1:"+mon);
		for (int i=0;i<100;)
		{
			i+=1;
			int d2= (int)MyDate3.next小分区(mon,  MyDate3.T_月,i);
			System.out.println("分区:"+i+":"+d2);

		}	
	}
	//@Test
	public void test_numToDate() {
	
	}

}
